<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>商品闪购列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="ebsig_container">

    <!--{include file='comm/menu.tpl'}-->
    <div class="comm_crub">
        <span class="now_crub">商品闪购列表</span>
    </div>
    <div class="comm_content">

            <div  class="search-box">
                <div style="position:relative">
                    <form id="searchForm" name="searchForm" onsubmit="return false;">
                        <table>
                            <tr>
                                <td>
                                    <span>商品编号：<input type="text" id="product_code" name="product_code" style="width: 100px;"></span>
                                    <span>商品名称：<input type="text" id="goodsName" name="goodsName"></span>
                                    <span>闪购日期：<input type="text" id="seckillTime" name="seckillTime" style="width: 100px;"></span>
                                    <span><input type="button" class="btn" value="查询" onclick="seckill.search();"></span>
                                    <span><input type="button" class="btn" value="重置" onclick="seckill.clear();"></span>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/promotion/seckill.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 100, align: 'center'},
            {display: "使用状态", width : 80, align: 'center'},
            {display: "闪购号", width : 80, align: 'right',  name : "kill_id", sortable : true},
            {display: "商家编码", width : 120 },
            {display: "商品名称", width : 350 },
            {display: "开始日期", width : 120, align: 'center'},
            {display: "结束日期", width : 120, align: 'center'},
            {display: "闪购价格", width : 60, align : 'right'},
            {display: "闪购总数量", width : 70, align : 'right'},
            {display: "已购买数量", width : 70, align : 'right'},
            {display: "“赞”数量 ", width : 70, align : 'right'}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "seckill.edit"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "seckill.del.confirm"}
        ],
        sortname: "kill_id",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true
    });

    var use_kill_id = '';   //变更状态时使用的ID

    var seckill = {

        /**
         * 查找
         */
        search : function() {
            var dt = $('#searchForm').serializeArray();
            $("#flex").flexOptions({newp: 1, params: dt}).flexReload();
        },

        /**
         * 重置表单
         */
        clear : function() {
            document.forms['searchForm'].reset();
        },

        change: {

            confim: function(id, useFlg) {

                this.id = id;
                if (useFlg == 0) {
                    E.confirm("您确认要启用该闪购吗？", "seckill.change.execute");
                } else {
                    E.confirm("您确认要禁用该闪购吗？", "seckill.change.execute");
                }

            },

            execute: function() {
                E.loadding.open("正在修改闪购活动状态，请稍候...");
                E.ajax_get({
                    url: "/invokingAjax-backend/promotion/seckill.ajax?operFlg=3",
                    data: {
                        id: this.id
                    },
                    call: "seckill.change.result"
                });
            },

            result: function( o ) {

                E.loadding.close();
                if (o.code == 200) {
                    E.alert(o.message, 2, "seckill.load");
                } else {
                    E.alert(o.message);
                }

            }

        },

        /**
         * 修改
         */
        edit : function (kill_id) {
            if (kill_id) {
                E.open("/quanliadmin/app/promotion/goodsSeckill.pscript?operFlg=3&kill_id=" + kill_id);
            } else {
                E.open("/quanliadmin/app/promotion/goodsSeckill.pscript?operFlg=2");
            }

        },

        /**
         * 删除
         */
        del : {

            confirm: function() {

                if ($(".trSelected").length == 0) {
                    E.alert("请选择要删除的闪购活动");
                } else {
                    E.confirm("您确认要删除选择的闪购活动吗？", "seckill.del.execute");
                }

            },

            execute: function() {

                var kill_array = new Array();
                $(".trSelected").each(function (k, v){
                    var id = $(v).attr("id").replace("row", "");
                    kill_array.push(id);
                });
                E.loadding.open("正在删除闪购活动状态，请稍候...");
                E.ajax_post({
                    url: "/invokingAjax-backend/promotion/seckill.ajax?operFlg=4",
                    data: {
                        kill_array: kill_array
                    },
                    call: "seckill.del.result"
                });

            },

            result: function( o ) {

                E.loadding.close();
                if (o.code == 200) {
                    E.alert(o.message, 2, "seckill.load");
                } else {
                    E.alert(o.message);
                }

            }

        },


        /**
         * 刷新列表
         */
        load : function(){
            $("#flex").flexReload();
        }

    };

	$('#seckillTime').datetimepicker();
</script>

</body>
</html>